package basic;

import java.util.Stack;

/**
 * @author Kevin
 * @date 2020/2/26 0:44
 */
public class Test {
    String hello = "hello";
    Test(){}

    public static void main(String[] args) {
//        Test t1 = new Test();
//        Test t2 = new Test();
//        System.out.println(t1.hello == t2.hello);
//        System.out.println(t1.hello == "hello");
//        System.out.println(t1.hello == new String("hello"));
//        System.out.println(t1.hello == new String("hello").intern());
        System.out.println(check("()"));
    }

    public static boolean check(String s) {
        Stack<Character> stack = new Stack();
        char[] c = s.toCharArray();
        for(char cc: c) {
            if(cc == '(') {
                stack.push(cc);
            } else {//如果是）
                if(!stack.empty()) stack.pop();
                else return false;
            }
        }
        if(!stack.empty()) return false;
        else return true;
    }
}
